<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件

if(!function_exists('myEcho')){
    function myEcho(&$data , $default = ''){
        if(!isset($data) || !$data){
            return $default;
        }

        return $data;
    }
}

if(!function_exists('arrayEmpty')){
    function arrayEmpty($data){
        $return         = [];
        foreach($data as $dk => $dv){
            if(is_array($dv)){
                $return = array_merge($return , arrayEmpy($dv));
            }else{
                if($dv != ''){
                    $return[$dk]        = $dv;
                }
            }
        }

        return $return;
    }
}

if(!function_exists('response')){
    function response($code = 200 , $data = '' , $msg = ''){
        $return                 = [ 'code' => 200 ];

        if($data !== ''){
            $return['data']     = $data;
        }

        if($msg !== ''){
            $return['msg']      = $msg;
        }

        echo json_encode($return);exit;
    }
}

if(!function_exists('dump')){
    function dump($data , $is_print = true){
        echo '<pre>';
            if($is_print){
                print_r($data);
            }else{
                var_dump($data);
            }
        echo '</pre>';exit;
    }
}